﻿<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title>账单列表页面</title>
    <!-- layui.css -->
    <link th:href="@{/plugin/layui/css/layui.css}"  rel="stylesheet" />
    <style>
        .layui-btn-small {
            padding: 0 15px;
        }

        .layui-form-checkbox {
            margin: 0;
        }

        tr td:not(:nth-child(0)),
        tr th:not(:nth-child(0)) {
            text-align: center;
        }

        #dataConsole {
            text-align: center;
        }
        /*分页页容量样式*/
        /*可选*/
        .layui-laypage {
            display: block;
        }

            /*可选*/
            .layui-laypage > * {
                float: left;
            }
            /*可选*/
            .layui-laypage .laypage-extend-pagesize {
                float: right;
            }
            /*可选*/
            .layui-laypage:after {
                content: ".";
                display: block;
                height: 0;
                clear: both;
                visibility: hidden;
            }

            /*必须*/
            .layui-laypage .laypage-extend-pagesize {
                height: 30px;
                line-height: 30px;
                margin: 0px;
                border: none;
                font-weight: 400;
            }
        /*分页页容量样式END*/
    </style>
</head>
<link type="text/css" rel="stylesheet"  th:href="@{/css/sweetalert2.css}" >
<link type="text/css" rel="stylesheet"  th:href="@{/css/admin/bootstrap/css/bootstrap.css}" >
<script th:src="@{/js/sweetalert2.js}"></script>
<script th:src="@{/js/jquery-1.11.3.min.js}"></script>
<script th:src="@{/js/sweetalert.min.js}"></script>
<body>
    <fieldset id="dataConsole" class="layui-elem-field layui-field-title"  style="display:none;">
        <legend>控制台</legend>
        <div class="layui-field-box">
            <div id="articleIndexTop">
                <form class="layui-form layui-form-pane" action="">
                    <div class="layui-form-item" style="margin:0;margin-top:15px;">
                        <div class="layui-inline">
                            <label class="layui-form-label">订单状态</label>
                            <div class="layui-input-inline">
                                <select name="status">
                                    <option value=""></option>
                                    <option value="0">免押申请</option>
                                    <option value="1">免押成功</option>
                                    <option value="2">免押支付中</option>
                                    <option value="3">免押支付失败</option>
                                    <option value="4">免押撤销中</option>
                                    <option value="5">免押撤销失败</option>
                                    <option value="6">免押撤销完成</option>
                                    <option value="7">申请失败</option>
                                    <option value="8">支付成功</option>
                                </select>
                            </div>
                            <label class="layui-form-label">手机号</label>
                            <div class="layui-input-inline">
                                <input type="text" name="keywords" autocomplete="off"  class="layui-input">
                            </div>
                            <div class="layui-input-inline" style="width:auto">
                                <button class="layui-btn" lay-submit lay-filter="formSearch">搜索</button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </fieldset>
    <fieldset id="dataList" class="layui-elem-field layui-field-title sys-list-field" style="display:none;">
        <legend style="text-align:center;">账单列表</legend>
        <div class="layui-field-box">
            <div  class="">
                <!--内容区域 ajax获取-->
                <table style="" class="layui-table" lay-even="">
                    <colgroup>
                        <col width="10">
                        <col width="50">
                        <col width="80">
                        <col width="80">
                        <col width="50">
                        <col width="200">
                        <col width="50">
                        <col width="80">
                        <col width="80">
                        <col width="80">
                        <col width="80">
                        <col width="80">
                        <col width="80">
                    </colgroup>
                    <thead>
                        <tr>
                            <th>编号</th>
                            <th>渠道</th>
                            <th>订单</th>
                            <th>姓名</th>
                            <th>手机号</th>
                            <th>收货地址</th>
                            <th>金额</th>
                            <th>状态</th>
                            <th>支付操作</th>
                            <th>物流操作</th>
                            <th>创建时间</th>
                            <th>支付时间</th>
                        </tr>
                    </thead>
                    <tbody id="dataContent">

                    </tbody>
                </table>
                <div id="pageNav"></div>
            </div>
        </div>
    </fieldset>
    <!-- layui.js -->
    <script th:src="@{/plugin/layui/layui.js}"></script>
    <!-- layui规范化用法 -->
    <script type="text/javascript">
        layui.config({
        	base: '../js/'
        }).use('order');

        function editPay(seqNo,source,userName) {
            swal(
                "请对客户：" + userName + "  的订单审核!",
                {    buttons: {
                        cancel: "取消操作",
                        catch: {
                            text: "撤销",
                            value: "unFreeze",
                            closeModal: false,
                        },
                        defeat: {
                            text: "支付",
                            value: "pay",
                            closeModal: false,
                        },
                    },
                }).then((value) => {
                switch (value) {
                case
                    "pay":
                    swal("支付中...", "你的支付请求已发送!", "success")
                        .then((value) => {
                        window.location.reload();
                });
                    $.ajax({
                        url: "/pay/credit/user/tradePay",
                        type: "post",
                        dataType: "json",
                        data: {
                            seqNo : seqNo
                        },
                        cache: false,
                        async: false
                    })
                    break;
                case
                    "unFreeze":
                    swal("正在撤销...", "你的撤销请求已发送!", "success")
                        .then((value) => {
                        window.location.reload();
                });
                    $.ajax({
                        url: "/pay/credit/user/fundAuthOrderUnFreeze",
                        type: "post",
                        dataType: "json",
                        data: {
                            seqNo : seqNo
                        },
                        cache: false,
                        async: false
                    })
                    break;
                default:
                    swal("主人等你考虑清楚在操作:)");
                }
            });
        };

        function editCourier(seqNo,source,userName){
            $.ajax({
                url: "/pay/data/courierQuery",
                type: "post",
                dataType: "json",
                data: {
                    seqNo : seqNo
                },
                cache: false,
                async: false,
                success: function(data) {
                    if (data.status === "0" ) {
                        Swal.fire({
                            title: "请填写 "+userName+" 的物流信息!",
                            text: "地址信息:"+source,
                            html:
                                '<input id="swal-input1" class="swal2-input"  placeholder="快递公司（必填）">' +
                                '<input id="swal-input2" class="swal2-input"  placeholder="快递编号（必填）">' +
                                '<input id="swal-input3" class="swal2-input"  required="required"  placeholder="快递价格（必填）" >' +
                                '<input id="swal-input4" class="swal2-input"  required="required" placeholder="数量（必填）" >',
                            /*               html 里面在调用ajax*/
                            focusConfirm: false,
                            preConfirm: () => {
                            $.ajax({
                                url: "/pay/data/courierInsert",
                                type: "post",
                                dataType: "json",
                                data: {
                                    seqNo : seqNo,
                                    courierNo : document.getElementById('swal-input2').value,
                                    courierCompany : document.getElementById('swal-input1').value,
                                    courierAmount : document.getElementById('swal-input3').value,
                                    num : document.getElementById('swal-input4').value
                                },
                                cache: false,
                                async: false,
                                success: function(data) {
                                    Swal.fire(JSON.stringify(data.msg));
                                }
                            })
                        }
                    })

                    }
                    if (data.status === "1" && data.data.status === 4) {
                        const courierNos=   data.data.courierNo;
                        const courierCompanys=   data.data.courierCompany;
                        Swal.fire({
                            title: userName+" 的物流已送达",
                            text: "地址信息:"+source,
                                })
                    } else  if (data.status === "1" && data.data.status === 1) {
                        const courierNo = data.data.courierNo;
                        const courierCompany = data.data.courierCompany;
                        Swal.fire({
                            title: "请将 " + userName + " 的物流处理成待发货",
                            text: "地址信息:" + source,
                            focusConfirm: false,
                            preConfirm: () => {
                                $.ajax({
                                    url: "/pay/data/courierUpdate",
                                    type: "post",
                                    dataType: "json",
                                    data: {
                                        seqNo: seqNo,
                                        status: 2
                                    },
                                    cache: false,
                                    async: false,
                                    success: function (data) {
                                        Swal.fire(JSON.stringify(data.msg));
                                    }
                                })
                            }
                         })
                    }else  if (data.status === "1" && data.data.status === 2) {
                            const courierNo=   data.data.courierNo;
                            const courierCompany=   data.data.courierCompany;
                            Swal.fire({
                                title: "请将 "+userName+" 的物流处理成派送中",
                                text: "地址信息:"+source,
                                focusConfirm: false,
                                preConfirm: () => {
                                    $.ajax({
                                        url: "/pay/data/courierUpdate",
                                        type: "post",
                                        dataType: "json",
                                        data: {
                                            seqNo : seqNo,
                                            status : 3
                                        },
                                        cache: false,
                                        async: false,
                                        success: function(data) {
                                            Swal.fire(JSON.stringify(data.msg));
                                        }
                                    })
                                }
                            })
                    }else  if (data.status === "1" && data.data.status === 3) {
                        const courierNo=   data.data.courierNo;
                        const courierCompany=   data.data.courierCompany;
                        Swal.fire({
                            title: "请将 "+userName+" 的物流处理成完成",
                            text: "地址信息:"+source,
                            html: '<a href="https://m.kuaidi100.com/app">快递100物流查询</a>',
                            focusConfirm: false,
                            preConfirm: () => {
                                $.ajax({
                                    url: "/pay/data/courierUpdate",
                                    type: "post",
                                    dataType: "json",
                                    data: {
                                        seqNo : seqNo,
                                        status : 4
                                    },
                                    cache: false,
                                    async: false,
                                    success: function(data) {
                                        Swal.fire(JSON.stringify(data.msg));
                                    }
                                })
                            }
                        })
                    }

                }
            })

        };
    </script>
</body>
</html>